<template>
  <div :style="{ minHeight: minHeight }" class="loading-wrapper">
    <slot v-if="!isLoading && !isEmpty"></slot>
    <div v-if="isLoading" class="loading-content mt-8">
      <slot name="loading">
        <span class="text-gray-400">加载中...</span>
      </slot>
    </div>
    <div v-if="isEmpty && !isLoading" class="empty-content">
      <slot name="empty">
        <div class="default-empty">暂无数据</div>
      </slot>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    isLoading: Boolean,
    isEmpty: Boolean,
    minHeight: {
      type: String,
      default: '200px'
    }
  }
}
</script>

<style scoped>
.loading-wrapper {
  position: relative;
}

.loading-content,
.empty-content {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100%;
}

.default-loading,
.default-empty {
  color: #666;
  padding: 20px;
}
</style>
